package com.jzo2o.orders.manager.ClientApi;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.jzo2o.api.customer.AddressBookApi;
import com.jzo2o.api.customer.dto.response.AddressBookResDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

//在这里调用远程调用 使方法被Sen形成粗点链路
@Component
@Slf4j
public class CustomerClient {
    @Resource
    private AddressBookApi addressBookApi;
    @SentinelResource(value = "getAddressBookDetail", fallback = "detailFallback", blockHandler = "detailBlockHandler")
    public AddressBookResDTO getDetail(Long id)
    {
        AddressBookResDTO detail = addressBookApi.detail(id);
        return detail;
    }


    public  AddressBookResDTO detailFallback(Long id, Throwable throwable)
    {
        log.error("异常抛出");
        return null;
    }

    public  AddressBookResDTO detailBlockHandler(Long id, Throwable throwable)
    {
        log.error("熔断");
        return null;
    }
}
